From 74f81dd1a5e3cfe3efb1dfc01177313be2dd5882 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 23 Mar 2005 09:07:45 +0000 Subject: [PATCH] bitkeeper revision 1.1159.272.9 (424131e1AxW6hgsgUY2M3meFO0k4MQ) libxc reacts to memory allocation delay because memory is on the scrub list. Signed-off-by: Keir Fraser --- tools/libxc/xc_private.h | 12 +++++++++++- xen/common/domain.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index c05ae491d9..a48156000a 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -72,7 +72,7 @@ static inline int do_xen_hypercall(int xc_handle, static inline int do_dom0_op(int xc_handle, dom0_op_t *op) { - int ret = -1; + int ret = -1, retries = 0; privcmd_hypercall_t hypercall; op->interface_version = DOM0_INTERFACE_VERSION; @@ -86,8 +86,18 @@ static inline int do_dom0_op(int xc_handle, dom0_op_t *op) goto out1; } + again: if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 ) { + if ( (errno == EAGAIN) && (retries++ < 10) ) + { + /* + * This was added for memory allocation, where we can get EAGAIN + * if memory is unavailable because it is on the scrub list. + */ + sleep(1); + goto again; + } if ( errno == EACCES ) fprintf(stderr, "Dom0 operation failed -- need to" " rebuild the user-space tool set?\n"); diff --git a/xen/common/domain.c b/xen/common/domain.c index fa07f2baf9..30b0677fbb 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -197,7 +197,7 @@ unsigned int alloc_new_dom_mem(struct domain *d, unsigned int kbytes) if ( unlikely((page = alloc_domheap_page(d)) == NULL) ) { domain_relinquish_memory(d); - return -ENOMEM; + return list_empty(&page_scrub_list) ? -ENOMEM : -EAGAIN; } /* Initialise the machine-to-phys mapping for this page. */ -- 2.30.2